//品牌管理
$(function(){
	$('#userList').getList({
		"initData":{
			"num":1,
			"size":10
		},
		"url":site.interUrl+"/sUsers/selectUserList",// 数据请求url
		"type":"get",
		"checkname":"datachk", //选择器名称，为空不显示选择器
		"col":[  //数据列
			{"field":"wxHeadPicUrl","display":"图片","width":"2","fun":"changePic"},
			{"field":"account","display":"账户","width":"2"},
			{"field":"userTypeDisplay","display":"用户类型","width":"2"},
			{"field":"nickName","display":"昵称","width":"2"},
			{"field":"isUsingDisplay","display":"是否启用","width":"1"},
			{"field":"createTime","display":"创建时间"}
		],
		"option":[ //操作按钮配置
			/*{"icon":"view","tip":"查看","fun":"brandView('{{id}}')"},  //icon: view,edit,add,del*/
			{"icon":"edit","tip":"编辑","fun":"usersEdit('{{id}}')"}  // 花括号内可以对应相关字段
			/*{"icon":"del","tip":"删除","fun":"deleteBrand('{{id}}')"}*/
		]
	});
	
	/*$("#userType").getSelect({
		type:"screen",
		label:"用户类型：",
		asName:"userType",
		code:"userType,type"
	});*/
	
	//批量删除
	$("#batchDelBtn").click(function(){
		var c = "";
		$("input[name=datachk]:checked").each(function(){
			c += $(this).val()+',';
		});
		if(c!= null && c!=''){
			deleteBrand(c);
		}else{
			ly.toast("请选择删除项");
		}
		
	});
});
//编辑
function usersEdit(id){
	ly.goto("user_view.html?id="+id);
}

//删除
function deleteBrand(id){
	var url = site.interUrl+"/banner/deleteBannerByIds";
	console.log(id);
	 request({
		url:url,
		data:{"ids":id},
		type:"get",
		callback:function(f) {
			console.log(f);
			if(f.code=="rest.success"){
			
				ly.toast("删除成功");
				$("#brandList").getList.refresh();//刷新当前分页
				
			}
		}
	});	
}
//查看
function commodityView(id){
	
	
}

function changePic(v, o, d) {
	console.log(d);
	if(d.wxHeadPicUrl!=null && d.wxHeadPicUrl!= ''){
		$(o).html("<img src="+d.wxHeadPicUrl+" width='30' height='30'>");
	}else{
		$(o).html("<img src='"+site.interUrl+"images/default_head.jpg' width='30' height='30'>");
	}
    
}